#ifndef __ELASTOS_DRIVER_ASSISTANT_H__
#define __ELASTOS_DRIVER_ASSISTANT_H__

#ifndef DRV_EXPRESSION
#ifdef  _DEBUG
#define ERRORLEVEL      10
#define WARNING         8
#define NORMALLEVEL     6
#define INFORMATION     4
#define DEBUGLEVEL      0

#define DRV_EXPRESSION(n, expression)                           \
            do {                                                \
            if (n >= NORMALLEVEL) {                             \
                switch(n) {                                     \
                case ERRORLEVEL:                                \
                    kprintf("ERROR: ");                         \
                    break;                                      \
                                                                \
                case WARNING:                                   \
                    kprintf("WARNING: ");                       \
                    break;                                      \
                                                                \
                case INFORMATION:                               \
                    kprintf("INFORMATION: ");                   \
                    break;                                      \
                                                                \
                case DEBUGLEVEL:                                \
                    kprintf("DEBUG: ");                         \
                    break;                                      \
                }                                               \
                expression;                                     \
                if (n >= WARNING) {                             \
                    kprintf(":--%s--%d--\n", __FILE__, __LINE__);\
                }                                               \
            }} while(0);
#else
#define     DRV_EXPRESSION(n, expression)   do {} while(0)
#endif  // _DEBUG
#endif  // DRV_EXPRESSION

#ifndef DRV_FAILED
#ifdef  _DEBUG
#define DRV_FAILED(ec)                                                  \
            (FAILED(ec)                                                 \
            && (kprintf(">>>Grafix failed, ec = 0x%08x, %s, %d\n",      \
                ec, __FILE__, __LINE__)))
#else
#define DRV_FAILED(ec)    FAILED(ec)
#endif // _DEBUG
#endif // DRV_FAILED


#endif // __ELASTOS_DRIVER_ASSISTANT_H__
